import 'package:flutter/material.dart';
import 'package:flutter_magic_planet/common/constant.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';

class FeedbackSheet extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 160,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(12),
          topRight: Radius.circular(12),
        ),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Container(
            width: Get.width,
            padding: EdgeInsets.symmetric(vertical: 12),
            decoration: BoxDecoration(
              color: Color(0xFFF2F2F3),
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(12),
                topRight: Radius.circular(12),
              ),
            ),
            child: Text(
              '欢迎您的所有意见和建议！',
              textAlign: TextAlign.center,
              style: TextStyle(
                color: Colors.black38,
                fontSize: 16,
              ),
            ),
          ),
          _buildAction(
            label: '邮件反馈：$email',
            color: Colors.white,
            onTap: () {
              launch("mailto:$email");
            },
          ),
          Divider(
            height: 1,
            indent: paddingHorizontal,
            endIndent: paddingHorizontal,
          ),
          _buildAction(
            label: '取消',
            color: Colors.white,
            onTap: () {
              Get.back();
            },
          ),
        ],
      ),
    );
  }

  _buildAction({label, onTap, color}) {
    return InkWell(
      onTap: onTap,
      child: Container(
        color: color,
        width: Get.width,
        padding: EdgeInsets.symmetric(vertical: 16),
        child: Text(
          label,
          textAlign: TextAlign.center,
          style: TextStyle(
            color: Colors.black87,
            fontSize: 16,
          ),
        ),
      ),
    );
  }
}
